/**
 * Mocking client-server processing
 */
export interface IProduct {
  id: number,
  title: string,
  price: number,
  // 商品库存
  inventory: number
}
const _products: IProduct[] = [
  { 'id': 1, 'title': '商务休闲夹克外套西装', 'price': 499.01, 'inventory': 2 },
  { 'id': 2, 'title': '空气感易打理快干弹力轻型长裤', 'price': 299.99, 'inventory': 10 },
  { 'id': 3, 'title': '快干条纹POLO衫', 'price': 149.99, 'inventory': 5 }
]

// 获取商品列表
export const getProducts = async () => {
  await wait(100)
  return _products
}
// 购买商品
export const buyProducts = async () => {
  await wait(100)
  return Math.random() > 0.5
}
// 模拟异步操作，获取数据延迟
async function wait(delay: number) {
  return new Promise((resolve) => setTimeout(resolve, delay))
}